#!/bin/bash

if [ $(id -u) = 0 ]
then
   echo "This script must not be run as root" 1>&2
   exit
fi


sh -c "echo '[Desktop Entry]
Type=Application
Name=Restart Network
;Exec=resolvectl dns $INTERFACE $SERVER
Exec=bash -c \"pkttyagent --process \\\\\\\\\`echo \\\\\\\\\$\\\\\\\\\$\\\\\\\\\` & pkexec bash -c \\\\\\\\\"for device in \\\\\\\\\\\\\\\\\\\\\\\\\$(nmcli device | grep \\\\\\\\\\\\\\\\\\\\\\\\\" connected\\\\\\\\\\\\\\\\\\\\\\\\\" | cut -f1 -d \\\\\\\\\\\\\\\\\\\\\\\\\" \\\\\\\\\\\\\\\\\\\\\\\\\"); do nmcli device disconnect \\\\\\\\\\\\\\\\\\\\\\\\\$device ; nmcli device connect \\\\\\\\\\\\\\\\\\\\\\\\\$device ;done\\\\\\\\\"\"
Icon=xfce4-weather
Terminal=true
' > $HOME/Desktop/NET-RESTART.desktop"

chmod a+x $HOME/Desktop/NET-RESTART.desktop

